$(function() {
	$("#editpasswd").bind("click", function() {
		var oldpwResult = checkPasswd($("#oldpasswd").val());
		if (!oldpwResult.result) {
			myalert(oldpwResult.msg);
			return false;
		}
		var newpwResult = checkPasswd($("#newpasswd").val());
		if (!newpwResult.result) {
			myalert(newpwResult.msg);
			return false;
		}
		var repwResult = checkRePasswd($("#newpasswd").val(), $("#renewpasswd").val());
		if (!repwResult.result) {
			myalert(repwResult.msg);
			return false;
		}
		showLoading();
		$.ajax({
			type : "post",
			url : appPath + "/setting/editpwsubmit.html",
			data : {
				oldpw : $.md5($("#oldpasswd").val() + $("#key1").val()),
				newpw : $.md5($("#newpasswd").val() + $("#key1").val()),
				key1 : $("#key1").val(),
				token : $.cookie("token")
			},
			success : function(result) {
				hideLoading();
				myalert(result.msg, function() {
					if (result.code == '1') {
						history.go(-1);
					} else if (result.code == '-1'){
						window.location = appPath + "/member/login.htm";
					}
				});
			},
			error: function(XMLHttpRequest, textStatus, errorThrown) {
				hideLoading();
	            myalert("系统异常，请稍后再试");
	        }
		});
	});
})